Task References

On this page:

push (array)

Purpose

The push (array) task is used to add an element to the end of an array. It dynamically appends the array upon which it is invoked and returns the new array.

Potential Use Case

For an upcoming network fiber roll out, you need to sort through multiple contact records to collect the email addresses of customers who live within a specific area code so that you can notify them of the availability of enhanced services. As these customers are found in the database, use the push (array) task to add their email addresses to an array through which a downstream email task can then loop through for sending notifications.

Properties

Input and output properties are shown below.

Incoming Type Description
arr Array Required. The target array to receive the pushed element.
elementN Any Required. The element to push.


Outgoing Type Description
pushedArray Array The array with the pushed element.

Examples

Example 1

In the IAP examples shown below:

  • The reference tasks (used to define the data source) selected for each incoming variable is job.

    pushArray

  • The reference variable set for each incoming variable is arr and elementN, respectively. As an option, you can toggle the Run Window slider to set the push (array) task to run on a schedule.

  • The array variables for push (array) are set prior to running the workflow.

    pushArray

    Note: If the array is empty, an error will be returned in the output.

    pushArray

  • Once you run the workflow, the variable names and incoming variables that were set are displayed under the Incoming tab in Task History, which is accessed from Job Manager.

    pushArray

  • The Outgoing tab displays the result of executing the push (array) task. Notice that "Device 3" was added to the end of the array.

    pushArray

Example 2

In this IAP example, a new array is created within our workflow, and the value of elementN is pushed into that new array.

  • The arr value is statically set as "[]", a pair of square braces.

  • The elementN value is statically set as the single string "Lemon".

  • The outgoing pushedArray variable will contain an array populated with one item ["Lemon"].

    pushArray

Example 3

Like the example above, a new array is created within our workflow. It is instantly populated with a 'space' value and then the value of elementN is pushed immediately into it.

  • The arr value is statically set as [" "], a pair of square braces with the string representation of a space.

  • The elementN value is statically set as the single string "Lemon".

  • The outgoing pushedArray variable will contain an array populated with two items [" ","Lemon"].

    pushArray

Additional Information

For general information on how to use tasks in Automation Builder, refer to the Tasks section in the Automation Studio documentation.